package top.forgirl.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import top.forgirl.common.group.Insert;
import top.forgirl.common.group.Search;
import top.forgirl.common.group.Update;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Getter
@Setter
@ToString
@ApiModel("需求记录模型DO")
public class DemandDo {

    @ApiModelProperty(value = "起始时间", example = "2021-01-01T00:00:00",notes = "查询结果中表示创建时间，查询条件中表示时间条件的起点")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime beginTime;

    @ApiModelProperty(value = "结束时间", example = "2021-01-01T00:00:00")
    private LocalDateTime endTime;

    @ApiModelProperty(value = "公司代号", required = true)
    @NotNull(message = "公司代号不能为空", groups = {Insert.class, Update.class})
    private String cId;

    @ApiModelProperty("需求物品代号")
    private String dId;

    @ApiModelProperty("需求的数量")
    @Min(value = 0, message = "数量不能为负数", groups = {Insert.class, Update.class})
    @NotNull(message = "数量不能为空", groups = {Insert.class})
    private Integer number;

    @ApiModelProperty("是否包含运费")
    private Integer containCostFlag;

    @ApiModelProperty(value = "截至日期", example = "2021-01-01T00:00:00", notes = "设定截止日期时，查找条件为设定日期之前的数据")
    @NotNull(message = "截至日期不能为空", groups = {Insert.class})
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime deadline;

    @ApiModelProperty("需求物品名")
    @NotBlank(message = "物品名不能为空或空串",groups = {Insert.class,Update.class})
    private String dName;

    @ApiModelProperty("需求物品的单位价格")
    @NotNull(message = "价格不能为空",groups = {Insert.class,Update.class})
    @Min(value = 0,message = "价格不能为负数",groups = {Insert.class,Update.class,Search.class})
    private Double price;

    @ApiModelProperty("目的地")
    private String toLocation;
}
